package com.ruoyi.web.controller.production;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mes.production.domain.SmesProductTechDetail;
import com.ruoyi.mes.production.service.ISmesProductTechDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品工艺明细Controller
 *
 * @author simpsense
 * @date 2020-12-03
 */
@RestController
@RequestMapping("/production/productTechDetail")
public class SmesProductTechDetailController extends BaseController
{
    @Autowired
    private ISmesProductTechDetailService smesProductTechDetailService;

    /**
     * 查询产品工艺明细列表
     */
    @PreAuthorize("@ss.hasPermi('production:productTechDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmesProductTechDetail smesProductTechDetail)
    {
        startPage();
        List<SmesProductTechDetail> list = smesProductTechDetailService.selectSmesProductTechDetailList(smesProductTechDetail);
        return getDataTable(list);
    }

    /**
     * 导出产品工艺明细列表
     */
    @PreAuthorize("@ss.hasPermi('production:productTechDetail:export')")
    @Log(title = "产品工艺明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SmesProductTechDetail smesProductTechDetail)
    {
        List<SmesProductTechDetail> list = smesProductTechDetailService.selectSmesProductTechDetailList(smesProductTechDetail);
        ExcelUtil<SmesProductTechDetail> util = new ExcelUtil<SmesProductTechDetail>(SmesProductTechDetail.class);
        return util.exportExcel(list, "productTechDetail");
    }

    /**
     * 获取产品工艺明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:productTechDetail:query')")
    @GetMapping(value = "/{rowId}")
    public AjaxResult getInfo(@PathVariable("rowId") Long rowId)
    {
        return AjaxResult.success(smesProductTechDetailService.selectSmesProductTechDetailById(rowId));
    }

    /**
     * 新增产品工艺明细
     */
    @PreAuthorize("@ss.hasPermi('production:productTechDetail:add')")
    @Log(title = "产品工艺明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmesProductTechDetail smesProductTechDetail)
    {
        return toAjax(smesProductTechDetailService.insertSmesProductTechDetail(smesProductTechDetail));
    }

    /**
     * 修改产品工艺明细
     */
    @PreAuthorize("@ss.hasPermi('production:productTechDetail:edit')")
    @Log(title = "产品工艺明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmesProductTechDetail smesProductTechDetail)
    {
        return toAjax(smesProductTechDetailService.updateSmesProductTechDetail(smesProductTechDetail));
    }

    /**
     * 删除产品工艺明细
     */
    @PreAuthorize("@ss.hasPermi('production:productTechDetail:remove')")
    @Log(title = "产品工艺明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{smesProductTechNo}")
    public AjaxResult remove(@PathVariable String smesProductTechNo)
    {
        return toAjax(smesProductTechDetailService.deleteSmesProductTechDetailByProductTech(smesProductTechNo));
    }
}
